{extend name="base" /}
{block name="body"}
<style type="text/css">
.mleft {
    margin-right: 10px;
}
</style>
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">账号管理</li>
            <li class="layui"><a href="{:url('/admin/jinling')}">旧平台SDK账号</a></li>
            <li class="layui"><a href="{:url('/admin/player/auth')}">实名信息查询</a></li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
            <div class="layui-form-item">
                <form class="layui-form layui-form-pane" action="{:url('/admin/player')}" method="get">
                    <div class="layui-inline mleft">
                        <label class="layui-form-label">玩家账号</label>
                        <div class="layui-input-inline" style="width: 120px;">
                            <input type="text" name="account" value="{:input('account')}" placeholder="请输入账号" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline mleft">
                        <label class="layui-form-label">玩家IP</label>
                        <div class="layui-input-inline" style="width: 120px;">
                            <input type="text" name="ip" value="{:input('ip')}" placeholder="请输入IP地址" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline mleft">
                      <label class="layui-form-label">游戏</label>
                      <div class="layui-input-inline" style="width: 120px;">
                        <select name="game" lay-filter="game" id="game" lay-search>
                            <option value="">请选择游戏</option>
						    {foreach name=":get_agent_game()" item="vo"}
							<option value="{$vo.id}"{if condition="$data.game == $vo.id"}selected{/if}>{$vo.name}</option>
							{/foreach}
                        </select>
                      </div>
                    </div>
                    <div class="layui-inline mleft">
                        <label class="layui-form-label">选择渠道</label>
                        <div class="layui-input-inline" style="width: 120px;">
                            <select name="cid" lay-filter="cid" id="cid" lay-search>
                                <option value=""{if condition="input('cid') == ''"}>请选择渠道</option>
                                <option value="0"{if condition="input('cid') === '0'"}selected{/if}>系统</option>
                                {foreach name=":get_channel_list()" item="vo"}
                                    <option value="{$vo.id}"{if condition="input('cid') == $vo.id"}selected{/if}>{$vo.platform}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline mleft">
                        <label class="layui-form-label">登录时间</label>
                        <div class="layui-input-inline" style="width: 150px;">
                            <input name="starttime" value="{:input('starttime')}" class="layui-input" placeholder="开始日" id="LAY_range_s">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline" style="width: 150px;">
                          <input name="endtime" value="{:input('endtime')}" class="layui-input" placeholder="截止日" id="LAY_range_e">
                        </div>
                    </div>
                    <input type="hidden" name="type" value="user">
                    <div class="layui-inline">
                        <button class="layui-btn">搜索</button>
                        <a id="exportBtn" href="#" class="layui-btn">导出</a>
                    </div>
                </form>
                </div>
                <hr>

                <table class="layui-table">
                    <thead>
                    <tr>
					    <th style="width: 30px;">ID</th>
                        <th style="width: 60px;">玩家账号</th>
                        <th style="width: 50px;">所属代理</th>
                        <th style="width: 60px;">游戏名称</th>
                        <th style="width: 60px;">注册方式</th>
                        {/*<th style="width: 60px;">区服名称</th>*/}
                        <th style="width: 80px;">登录IP</th>
                        <th style="width: 80px;">登陆时间</th>
						<th style="width: 30px;">状态</th>
                    </tr>
                    </thead>
                    <tbody>
						{foreach name="game_list" item="vo"}
						<tr>
							<td>{$vo.id}</td>
							<td>{$vo.account}</td>
							<td>{:get_channel_name($vo['cid'])}</td>
							<td>{:get_game_filed($vo['gid'],'name')}</td>
{/*							<td>{:get_server_filed($vo['sid'],'sname')&cc;</td>*/}
							<td>{eq name="$vo['type']" value = "0"}账号注册{/eq}{eq name="$vo['type']" value = "1"}手机号注册{/eq}</td>
                            <td>{$vo.login_ip}</td>
							<td>{:date("Y-m-d H:i:s",$vo['login_time'])}</td>
						    <td class="layui-form">
						        <div style="margin-top:-8px;">
						            <input data-url="{:url('admin/player/check')}"
						            data="{$vo['id']}" type="checkbox" name="checkbtn"
						            lay-filter="checkbtn" lay-skin="switch" lay-text="正常|封停"
						            {eq name="$vo['status']" value="1"}checked=""{/eq}>
						        </div>
						    </td>
						</tr>
						{/foreach}
                    </tbody>
                </table>
                <!--分页-->
				{:$reg_list->render()}
            </div>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script>
layui.use(['jquery','laydate'],function () {
    var laydate = layui.laydate;
    var $ = layui.$;

    $('#exportBtn').on('click', function() {
        // var formDataArray = $('form').serializeArray();
        $('form').attr('action', '{:url("/admin/export")}').submit();
    });
var startDate = layui.laydate.render({
  elem: '#LAY_range_s',
  min: '2017-12-28',
    type: 'datetime',
    //btns: ['confirm'],
  done:function(value,date){
    if( value !== '' ){
      endDate.config.min.year = date.year;
      endDate.config.min.month = date.month - 1;
      var day = date.date;
      if(date.hours == 23 && date.minutes == 59 && date.seconds == 59){
        day = day + 1;
      }else{
        endDate.config.min.hours = date.hours;
        endDate.config.min.minutes = date.minutes;
        endDate.config.min.seconds = date.seconds;
      }
      endDate.config.min.date = day;
      endDate.config.btns = ['clear','confirm'];
    }else{
      endDate.config.min.year = '';
      endDate.config.min.month = '';
      endDate.config.min.date = '';
      endDate.config.min.hours = '';
      endDate.config.min.minutes = '';
      endDate.config.min.seconds = '';
      endDate.config.btns = ['clear','now','confirm'];
    }
  }
});


var endDate = layui.laydate.render({
  elem: '#LAY_range_e',
  min: '2017-12-28',
    type: 'datetime',
    //btns: ['confirm'],
  done:function(value,date){
    if( value !== '' ){
      startDate.config.max.year = date.year;
      startDate.config.max.month = date.month - 1;
      var day = date.date;
      if(date.hours == 0 && date.minutes == 0 && date.seconds == 0){
        day = day - 1;
      }else{
        startDate.config.max.hours = date.hours;
        startDate.config.max.minutes = date.minutes;
        startDate.config.max.seconds = date.seconds;
      }
      startDate.config.max.date = day;
      startDate.config.btns = ['clear','confirm'];
    }else{
      startDate.config.max.year = '';
      startDate.config.max.month = '';
      startDate.config.max.date = '';

      startDate.config.max.hours = '';
      startDate.config.max.minutes = '';
      startDate.config.max.seconds = '';
      startDate.config.btns = ['clear','now','confirm'];
    }
  }
});
});

layui.use(['form', 'laydate'], function(){
    var form = layui.form;
     var laydate = layui.laydate;

	//监听开启开关
      form.on('switch(checkbtn)', function(data){
        var url  = $(this).attr('data-url');
    	var date = $(this).attr('data');
    	var type = this.checked ? 1:0;
    	$.post(url,{id:date,type:type},function(info){
    	    layer.msg(info.msg);
    		})
    });
});

</script>
{/block}